#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 6.3.22 9:29 AM
# @File    : run.py
import pytest
import time
import os
import shutil
from utils.path_manager import Path

# case 路径
CASE_DIR = Path().get_case_path()

# result 路径
RESULT_DIR = Path().get_result_path()
# report路径
REPORT_DIR = Path().get_report_path()

if __name__ == '__main__':
    now = time.strftime("%Y%m%d%H%M%S")
    pytest.main(['-s', '-q', CASE_DIR, '--alluredir',
                 os.path.join(RESULT_DIR, 'result-{0}'.format(now))])
    shutil.copyfile(os.path.join(RESULT_DIR,'environment.properties'),
                    os.path.join(RESULT_DIR, 'result-{0}'.format(now), 'environment.properties'))
    shutil.copyfile(os.path.join(RESULT_DIR,'categories.json'),
                    os.path.join(RESULT_DIR, 'result-{0}'.format(now), 'categories.json'))
    os.system('allure generate {} -o {}'.format
              (os.path.join(RESULT_DIR, 'result-{}'.format(now)),
               os.path.join(REPORT_DIR, 'report-{}'.format(now))))